﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.Profile;


public partial class UserControls_Register : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
      errorBox.Visible = false;
      lblTerms.Visible = false;
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
      if (!IsFormsValid())
      {
        ShowError();
        return;
      }

      //var member = Membership.CreateUser(txtEmail.Text, txtPass.Text, txtEmail.Text);
      //Roles.AddUserToRole(member.UserName, "BasicUsers");

      //var profile = ProfileBase.Create(member.UserName);
      //profile["memberFirstName"] = txtFirstName.Text;
      //profile["memberLastName"] = txtLastName.Text;
      //profile.Save();
    }

    private void ShowError()
    {
      if (!chbAccept.Checked)
      {
        lblTerms.Visible = true;
        lblTerms.Text = "<li>Accepter betingelserne</li>";
      }
      errorBox.Visible = true;
    }

    private bool IsFormsValid()
    {
      return Page.IsValid && chbAccept.Checked ? true : false;
    }
}